/*
 License
 
 Copyright © 2012 Kevin Kimmich
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights to 
 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 the Software, and to permit persons to whom the Software is furnished to do so, 
 subject to the following conditions:
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


/**
 @file
 Wrappers for pthread_create().
 */

#ifndef _core_thread_h
#define _core_thread_h

#ifdef __cplusplus
extern "C" {
#endif


#include "crcore.h"

/*!
 Initialize the core thread static structures.
 */
void core_thread_init(void);

/*!
 Create a new thread.
 @param func The core thread funciton.
 @param argc The number of arguments in the argv array.
 @param argv Arguments to pass to the function.
 */
core_thread_t* core_thread_create(void*(*func)(int,void**), int argc, void** argv);

/*!
 Create a new thread, do not detach.
 @param func The core thread funciton.
 @param argc The number of arguments in the argv array.
 @param argv Arguments to pass to the function.
 */
core_thread_t* core_thread_create_attached(void*(*func)(int,void**), int argc, void** argv);


/*!
 Frees up any resources associated with the "core_thread_create" function.
 @param th The core thread.
 */
void core_thread_destroy(core_thread_t* th);

/*!
 Stores the item in thread local storage. This item is not visible to other threads.
 @param key A string to associate with the item.
 @param item The item to associate with the key.
 */
void core_thread_set_item(char* key, void* item);

/*!
 Retrieves the item from thread local storage.
 @param key The string associated with the item.
 */
void* core_thread_get_item(char* key);

#ifdef __cplusplus
}
#endif

	
#endif //_core_thread_h
